#pragma once
#include"hash.h"
namespace bit
{
	using namespace hash_bucket;
	template<class K>
	class unorderded_set
	{
	public:

		struct setKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};


		typedef typename HashTable<K,const K, setKeyOfT>::Iterator iterator;
		typedef typename HashTable<K,const K, setKeyOfT>::ConstIterator const_iterator;


		pair<iterator, bool> insert(const K& data)
		{
			return _pht.Insert(data);
		}
		bool erase(const K& key)
		{
			return _pht.Erase(key);
		}
		iterator find(const K& key)
		{
			return _pht.Find(key);
		}

		iterator begin()
		{
			return _pht.Begin();
		}
		iterator end()
		{
			return _pht.End();
		}
		const_iterator begin()const
		{
			return _pht.Begin();
		}
		const_iterator end()const
		{
			return _pht.End();
		}


	private:

		HashTable<K,const K, setKeyOfT> _pht;
	};

	void test_set()
	{

		unorderded_set<int> s;
		int a[] = { 4,2,6,1,3,5,15,7,16,14,82,34 };


		for (auto e : a)
		{
			s.insert(e);
		}

		//cout << s.find(4) << endl;


		for (auto e : a)
		{
			s.erase(e);
		}

	}

	void Print1(const unorderded_set<int>& s)
	{
		unorderded_set<int>::const_iterator c_ito = s.begin();

		while (c_ito != s.end())
		{
			//*c_ito+=10;
			cout << *c_ito << ' ';
			++c_ito;
		}
	}

	void test_unordered_set1()
	{

		unorderded_set<int> s;
		int a[] = { 4,2,6,1,3,5,15,7,16,14,82,34 };


		for (auto e : a)
		{
			if (e == 14)
			{
				int k = 0;
			}

			s.insert(e);
		}

		//cout << s.find(4) << endl;


		unorderded_set<int>::iterator ito = s.begin();

		while (ito != s.end())
		{
			cout << *ito << ' ';
			if (*ito == 16)
			{
				int k = 0;
			}

			++ito;
		}
		cout << endl;

		for (auto e : s)
		{
			cout << e << ' ';
		}
		cout << endl;



	}




}